<template>
  <view class="language-switch" @tap="handleChangeLang">
    {{ currentLanguageComputed }} 全局
    <view class="icon icon-change"></view>
  </view>
</template>

<script name="language-switch" setup>
import useI18nStore from '@/store/modules/i18nStore';
import {useI18n} from 'vue-i18n';

const {locale} = useI18n();
const i18nStore = useI18nStore();
const currentLanguageComputed = computed(() => {
  console.log('测试');
  
  return i18nStore.language === 'zh' ? '英文' : '简体中文'
  
});

// 国际化切换
function handleChangeLang() {
  const lang = i18nStore.language === 'zh' ? 'en' : 'zh';
  locale.value = lang; // 设置语言
  i18nStore.setLanguage(lang); // 设置store语言
}
</script>

<style lang="scss" scoped>
.language-switch {
  
}
</style>